﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// Summary description for dbInsert
/// </summary>
public class dbInsert
{
	public dbInsert()
	{
		//
		// TODO: Add constructor logic here
		//
	}



    private static string connString
    {

        get
        {
            //return ConfigurationManager.ConnectionStrings["devTmsEPrd"].ConnectionString;
            //return ConfigurationManager.ConnectionStrings["prodTmsEPrd"].ConnectionString;
            // return ConfigurationManager.ConnectionStrings["prod"].ConnectionString;
            return ConfigurationManager.ConnectionStrings["prod"].ConnectionString;
        }
    }


    private void InsertUsingSP(string fname, string lname, string add, string city, string state, string zip, string email, string cemail, string phone)
    {


         using (SqlConnection myConn = new SqlConnection(connString))
        {
            try
            {
                 myConn.Open();


                 SqlCommand myCmd = new SqlCommand("CUS_sp_transfer_INSERT", myConn);
                 myCmd.CommandType = CommandType.StoredProcedure;
                 myCmd.Parameters.Add("@first_name", SqlDbType.VarChar).Value = fname;
                 myCmd.Parameters.Add("@last_name", SqlDbType.VarChar).Value = lname;
                 myCmd.Parameters.Add("@email", SqlDbType.VarChar).Value = email;
                 myCmd.Parameters.Add("@confirmemail", SqlDbType.VarChar).Value = cemail;
                 myCmd.Parameters.Add("@phone", SqlDbType.VarChar).Value = phone;
                 myCmd.Parameters.Add("@address", SqlDbType.VarChar).Value = add;
                 myCmd.Parameters.Add("@city", SqlDbType.VarChar).Value = city;
                 myCmd.Parameters.Add("@state", SqlDbType.VarChar).Value = state; 
                myCmd.Parameters.Add("@zip", SqlDbType.VarChar).Value = zip;

                 myCmd.ExecuteNonQuery();


            }

            catch (SqlException ex)
            {

                string errMsg = "Sql Exception Caught " + ex.Message.ToString();
                

            }
            finally
            {

                myConn.Close();
            }

        }



    }


}
